<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: class.radio_thmb.php 561 2015-02-28 12:34:42Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 561 $
* 	zuletzt geaendert von:	$Author: $
* 	Datum:					$Date: 2015-02-28 12:34:42 +0000 (Sat, 28 Feb 2015) $
*
* 	extends by dirk.mueller (edv-mueller.com)
* 	http://www.itdotmedia.de
*
* --------------------------------------------------------------------------------------
* 	based on:
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
* 	Copyright (c) since 2011 SEO:mercari
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */
include_once (DIR_WS_INCLUDES.'modules/product_konfigurator/class.base.php');

class radio_thmb extends base {

  function assign_template(&$smarty, $product_id) {
    global $db;

    $option_smarty = new Smarty();
    if (!$this->assign_template_base($option_smarty, $product_id)) return;
    $template_name = $option_smarty->getTemplateVars('TEMPLATE');

    $sql = "
      select
      	o.konfigurator_options_id, o.konfigurator_options_name,
      	o.konfigurator_options_parameter,
      	po.is_default
      from
      	".TABLE_KONFIGURATOR_PRODUCT_OPTION." po
      	inner join ".TABLE_KONFIGURATOR_OPTIONS." o
      		on po.konfigurator_option = o.konfigurator_options_id
      where
      	po.product_id = '".$product_id."'
      	and po.konfigurator_option_group = '".$this->group['id']."'
      	and po.konfigurator_option != 'HAVE_TO'
      order by
      	o.konfigurator_options_sort";
    $query = $db->db_query($sql, true);

    $options = array();
		if($query->_numOfRows > 0){
			while(!$query->EOF){
        $p = $this->parse_parameters($query->fields['konfigurator_options_parameter']);
        $option = array(
          'ID'    => $query->fields['konfigurator_options_id'],
          'NAME'  => $query->fields['konfigurator_options_name'],
          'HELP'  => isset($p['help']) ? $p['help'] : '',
          'IMG'   => isset($p['img']) ? $p['img'] : 'no-pic.jpg',
          'STD'   => ($query->fields['is_default'] == 'true')
        );
        $options[] = $option;
        $query->moveNext();
      }
    }
    $option_smarty->assign('OPTIONS', $options);

  	$option_smarty->assign('language', $_SESSION['language']);
  	if (!CacheCheck()) {
      $option_smarty->caching = false;
      $option_box = $option_smarty->fetch(CURRENT_TEMPLATE.'/module/product_konfigurator/'.$template_name);
    } else {
      $option_smarty->caching = true;
      $option_smarty->cache_lifetime = CACHE_LIFETIME;
      $option_smarty->cache_modified_check = CACHE_CHECK;
      $cache_id = $product->data['products_id'].$this->group['id'].$_SESSION['language'].$_SESSION['customers_status']['customers_status_name'];
  		$option_box = $option_smarty->fetch(CURRENT_TEMPLATE.'/module/product_konfigurator/'.$template_name, $cache_id);
    }
    
    $MODULE_product_options = $smarty->getTemplateVars('MODULE_product_options');
    if ($MODULE_product_options != '') $MODULE_product_options .= "\n";
    $smarty->assign('MODULE_product_options', $MODULE_product_options . $option_box);
  }
  
}